package io.sofastack.demo.controller;

import com.alipay.sofa.ark.api.ArkClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

/**
 * index controller
 *
 * @author caojie.cj@antfin.com
 * @since 2020/2/11
 */
@RestController
public class BizController {

    @RequestMapping(value = "/installBiz", method = RequestMethod.POST)
    public void installBiz(String url) throws Throwable {
        ArkClient.installBiz(new File(url));
    }

    @RequestMapping(value = "/uninstallBiz", method = RequestMethod.POST)
    public void uninstallBiz(String bizName, String bizVersion) throws Throwable {
        ArkClient.uninstallBiz(bizName, bizVersion);
    }

    @RequestMapping(value = "/switchBiz", method = RequestMethod.POST)
    public void switchBiz(String bizName, String bizVersion) {
        ArkClient.switchBiz(bizName, bizVersion);
    }

}
